package com.wing.cabinet.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 刀柜货道
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cab_cabinet_cargo_lane")
public class CabinetCargoLane extends BaseEntity<CabinetCargoLane> implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.INPUT)
    private Long id;

    public enum StockStatus implements IEnum<Integer> {

        /**
         * 正常
         */
        normal(0,"正常"),
        /**
         * 告警
         */
        alert(1,"告警"),
        /**
         * 急需补货
         */
        replenishment(2,"急需补货");

        private int code;
        private String desc;

        StockStatus(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    public enum Status implements IEnum<Integer> {

        /**
         * 正常
         */
        normal(0,"正常"),
        /**
         * 异常
         */
        abnormal(1,"异常");

        private int code;
        private String desc;

        Status(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 编号
     */
    private String code;

    /**
     * 货道编号
     */
    private String laneCode;

    /**
     * 入驻企业ID
     */
    private Long settledCompanyId;

    /**
     * 刀柜ID
     */
    private Long cabinetId;

    /**
     * 产品ID
     */
    private Long productId;

    /**
     * 产品SKU
     */
    private String productSku;

    /**
     * 货道承载数量
     */
    private Integer quantity;


    /**
     * 货道当前库存数
     */
    private Integer currentStockCount;

    /**
     * 刀柜自编码
     */
    private String cabCode;
    /**
     * 刀柜编码
     */
    private String cabinetCode;

    /**
     * 库存状态
     */
    private StockStatus stockStatus;

    /**
     * 库存状态描述
     */
    @TableField(exist = false)
    private String stockStatusDesc;

    public String getStockStatusDesc() {
        return stockStatus == null ? null : stockStatus.getDesc();
    }
    /**
     * 状态
     */
    private Status status;

    /**
     * 状态描述
     */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * 货道类型id
     *
     */
    private Long spaceTypeId;

    private String remark;

    /**
     * 最大承重
     */
    private BigDecimal maxBearing;

    /**
     * 最大体积
     */
    private BigDecimal maxVolume;



    /**
     * 权责人
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long principal;

    /**
     * 入柜产品类型
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long spaceProductType;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String skuCode;



    public enum SpaceType implements IEnum<Integer> {

        common(0,"公共"),
        /**
         * 暂存
         */
//        temp(1,"暂存"),
                normal(1,"可用"),
        /**
         * 维修
         */
        repair(2,"维修"),
        /**
         * 回收
         */
        recycle(3,"回收");

        private int code;
        private String desc;

        SpaceType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static SpaceType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (SpaceType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    //    @TableField(fill = FieldFill.INSERT_UPDATE)
    private CabinetCargoSpace.SpaceType spaceType;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String principalName;

    /**
     * 企业编码
     */
    private String enterpriseCode;
}
